<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>企业浏览</title>
<link type="text/css" href="../../css/shCompany.css" rel="stylesheet" >
<link type="text/css" href="../../js/jDialog/jDialog.css" rel="stylesheet" >
<script type="text/javascript" src="../../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../js/jDialog/jquery.dialog.js"></script>
</head>
<script type="text/javascript" >
var sumPage=1;//总页数
var nowPage=1;//当前页数
var nowCount=1;//一页显示的条数
var sumCount=0;//总条数
var nowMin=1;//当前显示第一排的序号
var nowMax=1;//当前显示最后第一排的序号
var companyObj =window.companyObj;
var companyId = companyObj[0].companyId;
var RecObj=null;
var i;
$(document).ready(function() {
	$.initFrame();
	if(sumCount == 0){
		$("#tableInfo").append("<tr><td colspan='5'>没有数据</td></tr>");
		$.InitValue(0,0);
	}else{
		if(sumCount%nowCount==0)
			sumPage=sumCount/nowCount;
		else
			sumPage=Math.floor(sumCount/nowCount)+1;//根据记录数和每页显示条数获取总页数
		$.InitValue(1,nowMax);
	}
	$.checkPagesnum();
});
$.initFrame = function(){
	$.ajax({
		type : 'post',
		dataType : 'text',
		async: false,
		url : '../../company/getRecruitByCompanyId.action',
		data:{
			"companyDTO.companyId":companyId
		},
		success : function(msg) {
			if(msg.length<=4){
				sumCount=0;
			}else{
				RecObj = JSON.parse(msg);
				sumCount = RecObj.length;
	 			for(i=0;i<nowCount;i++)
	 				$.appendTip(i);
	 			nowMin=1;
	 			nowMax=i;
			}
 			$("#sumCount").html(sumCount);
		}
	});
}
$.appendTip = function(j){
	$("#tableInfo").append("<tr><td>"+(j+1)+"</td><td>"+RecObj[j].recruitmentPosition+"</td><td>"+RecObj[j].recruitmentNum+"</td><td>"+RecObj[j].recruitmentAreNum+"</td><td><input type='button' value='修  改' onclick='$.deliverResum("+RecObj[j].recruitmentId+",1)' class='opbun'/>&nbsp;&nbsp;&nbsp;<input type='button' value='删  除' onclick='$.deliverResum("+RecObj[j].recruitmentId+",-1)' class='opbun' style='background-color:#DC143C;'/></td></tr>");
}
$.addJob = function(){
	var dialog = jDialog.iframe('addRecruitmentInfo.html?companyId='+companyId,{
		title : "添加信息",
		width : 500,
		height : 500,
	});
}
$.deliverResum = function(Id,options){
	if(options == 1){
		var dialog = jDialog.iframe('recruitDetailedInfo.html?recruitmentId='+Id,{
			title : "职位信息",
			width : 500,
			height : 500,
		});
	}
	else{
		/* window.parent.reloadPage(); */
		 var dialog = jDialog.confirm('您确定要删除该信息?',{
			handler : function(button,dialog) {
				$.ajax({
					type : 'post',
					dataType : 'text',
					data:{
						"recruitmentEasyDTO.recruitmentId":Id,
					},
					url : '../../company/deleJob.action',
					success : function(msg) {
						if(msg==1){
							alert("删除成功");
						}
						else
							alert("删除失败")
					}
				}); 
				dialog.close();
			}
		},{
			handler : function(button,dialog) {
				dialog.close();
			}
		});
	}
}
</script>
<script type="text/javascript" src="../../js/showInfolist.js"></script>
<body>
<div class="mineInfo">
<span id="info1">招聘信息&nbsp;REQUIREMENT</span>
<hr style="height:1px;border:none;border-top:1px solid #555555;" />
</div>
<div id="seleDiv">
<span>一页显示</span><select onchange="$.changCount(this)"><option selected="selected">1</option><option>2</option><option>3</option><option>4</option><option>5</option></select><span>条记录</span>
&nbsp;&nbsp;<input type="button" value="添  加" title="添加职位" onclick="$.addJob()" class='opbun' style='background-color:#7CCD7C;'>
</div>
<table id="tableInfo" border="1" rules="rows">
<tr>
<th width="15%">序号</th>
<th width="15%">职位</th>
<th width="15%">招聘人数</th>
<th width="15%">已招人数</th>
<th width="24%">操作</th>
</tr>
</table>
<div id="pageButton">
<a>当前显示<span id="firtLine" style="font-weight:bold;">0</span><span>到</span><span id="lastLine" style="font-weight:bold;">0</span><span>条,共</span><span id="sumCount" style="font-weight:bold;">2</span><span>条记录</span></a>
<a>第<span style="font-weight:bold;" id="nopage">1</span>/<span style="font-weight:bold;" id="alpage">1</span>页</a>
<span id="cpage"><a onclick="$.firstPage()" id="fipage">首页</a>
<a onclick="$.formPage()" id="fopage">上一页</a>
<a onclick="$.nextPage()" id="nepage">下一页</a>
<a onclick="$.lastPage()" id="lapage">尾页</a></span>
</div>
</body>
</html>